﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using libSyllabus.DataModel;
using libSyllabus.Model;

namespace libSyllabusDebugHelper
{
    class Program
    {
        static MainDataContext DB;

        static void Main(string[] args)
        {
            /* Well, you can see that a bunch of hard-ass code in libSyllabus
             * made database connection as easy as this.
             * 
             * In this debug helper program, I delete existing database, create a new one,
             * insert a semester entry ans query it.
             */
            Console.WriteLine("Creating DataContext Object...");
            DB = new MainDataContext("D:\\My Documents\\syllabus.sdf");
            Console.WriteLine("Deleting Existing Database...");
            if (DB.DatabaseExists()) DB.DeleteDatabase();
            Console.WriteLine("Creating New Database...");
            DB.CreateDatabase();

            Console.WriteLine("Inserting Semester Entry...");
            DB.Semesters.InsertOnSubmit(new SemesterEntity() { Year = 2011, Title = "Fall", StartDate = new DateTime(2011, 8, 22), EndDate = new DateTime(2011, 12, 17) });
            Console.WriteLine("Submitting Changes...");
            DB.SubmitChanges();

            Console.WriteLine("Executing Query...");
            var sems = from S in DB.Semesters select S;
            Console.WriteLine("Transforming Query into Immediate Fetch Collection...");
            SemesterEntity[] arrsems = sems.ToArray();

        }

        static void BuildSampleDatabase()
        {
            

        }
    }
}
